<%--
  Created by IntelliJ IDEA.
  User: dzw
  Date: 2017/12/8
  Time: 15:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";

%>

<div id="page-content">
  <div class="row">

    <div class="col-lg-12">
      <div class="panel">
        <div class="panel-heading">
          <h3 class="panel-title">物品申请</h3>
        </div>
        <div class="panel-body">
          <div class="form-inline">
            <div class="row">
              <div class="col-sm-12 table-toolbar-left">
                <btn id="btn_add_goodsApply" class="btn btn-primary btn-sm" ${isStart}>
                  <i class="ti-plus"> </i> 新建物品申请
                </btn>
              </div>
            </div>
          </div>
          <div class="table-jqgrid">
            <table id="goodsApply_table"></table>
            <div id="goodsApply_page"></div>
          </div>
        </div>
      </div>
    </div>

  </div>
</div>

<script>

  $(function(){

    init_grid_goodsApply();

  });

  function init_grid_goodsApply() {
    __init_jqgrid('goodsApply_table', 'goodsApply_page',
            '<%=path%>/com/goodsApply/list?viewtype=${viewtype}',
            ['物品用途',"合计金额",'申请人',"申请时间",<c:if test="${viewtype==1}">"审批人",</c:if><c:if test="${viewtype==2}">"领用情况",</c:if>"操作","id"],
            [
              {name:'purpose',index:'purpose', width:100,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
              {name:'numMoney',index:'numMoney', width:100,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
              {name:'creater',index:'creater', width:100,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
              {name:'createrDate',index:'createrDate', width:100,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
              <c:if test="${viewtype==1}">
              {name:'editor',index:'editor', width:100,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
              </c:if>
              <c:if test="${viewtype==2}">
              {name:'useCondition',index:'useCondition', width:100,search:true,sortable:true, searchoptions: {sopt: ['cn']}},
              </c:if>
              {name:'act',index:'act', width:210,sortable:false,search:false,fixed:true,formatter: actFormat},
              {name:'id',index:'id',search:false,hidden:true}
            ],
            true,true
    );
  }

  function actFormat(cellvalue, options, rowObject){
    var id = rowObject.id;
    cellvalue = '<button class="btn btn-white btn-sm" onclick="fn_goodsApply_read(\'' + id + '\');"><i class="fa fa-eye"> </i> 查看</button>';
    return cellvalue;
  }

  function fn_goodsApply_read(id) {
    loadURL('<%=path%>/com/goodsApply/read?keyId='+id+'&viewtype=${viewtype}', $('#page-content'));
  }

  $("#btn_add_goodsApply").click(function(){
    loadURL('<%=path%>/com/goodsApply/input', $('#page-content'));
  });

</script>